<template>
	<view class="page">
		<view class="bot content">
			<view class="botzise">热门品牌</view>
			<view class="list">
				<view class="col" v-for="(item,index) in list.slice(1,11)" @click="bran(item.id)">
					<image :src="item.brandImg"></image>
					<view class="writing">{{item.brandName}}</view>
				</view>
			</view>


		</view>
		<view class="content">
			<TindexList @brands="nue"></TindexList>

			<!-- 	<u-index-list sticky="true" :index-list="indexList" :selectitem="true">
		
					<u-index-item v-for="(item, index) in itemArr">
						<u-index-anchor bgColor="#F8F8F8" :text="indexList[index]"></u-index-anchor>
						<view class="list-cell" v-for="(cell, index) in item" :key="index"  @click="bran(cell.id)">
							{{cell.id}}
								<image :src="cell.brandImg" style="width: 80rpx;height: 80rpx;"></image>
								<view class="cell">{{cell.brandName}}</view>
		

						</view>
					</u-index-item>
		
			</u-index-list> -->

		</view>
	</view>
</template>

<script>
	import {
		apisortByInitial11
	} from '@/api/car.js'
	import TindexList from "./indexlist.vue"
	export default {
		data() {

			return {
				list: [],
				indexList: [],
				itemlist: []
			}
		},
		created() {
			this.sortByInitial()
		},
		components: {
			TindexList
		},
		methods: {
			nue() {
				this.$emit("brand")
			},
			bran(id) {
				console.log(id)
				this.$store.commit("setbrand", id)
				this.nue()
			},

			sortByInitial() {
				uni.showLoading({
					title: '加载中'
				})

				apisortByInitial11().then(res => {
					for (let item in res.data) {
						res.data[item].forEach(item => {
							this.list.push(item)
						})
					}
					uni.hideLoading()
					// res.data.fo((item,index)=>{
					// 	// let li =[]
					// 	console.log(item)
					// 	// li.push(item.[index])
					// })

				})
			}
		},

	}
</script>

<style scoped lang="scss">
	.page {
		position: relative;
	}

	.content {
		margin-top: 20rpx;
		margin: 30rpx;
		background-color: #fff;
		border-radius: 10rpx;
	}

	.bot {
		padding: 16rpx;

		.botzise {
			font-size: 34rpx;
			margin-bottom: 10rpx;
		}

		.list {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.col {
				margin-right: 10rpx;
				margin-top: 18rpx;
				width: 120rpx;
				text-align: center;

				image {
					width: 72rpx;
					height: 72rpx;
				}

				.writing {
					font-size: 28rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
			}

			.col:nth-of-type(5n+0) {

				margin-right: 0;

			}
		}
	}

	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
		border-bottom: #c3c3c7 1rpx solid;

		.cell {
			margin: 15rpx;
			font-size: 32rpx;
			font-weight: 500;
		}
	}
</style>